﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2
{
    public class DbHelper
    {
        private static readonly string connectionString = "server= ;datdabase=master;uid=sa;pwd=12345";
        private static object cmd;

        public static SqlDataReader Query(string cmdString)
        {
            SqlConnection sqlConnection = new SqlConnection(connectionString);

            using(SqlCommand command=new SqlCommand(cmdString, sqlConnection))
            {
                sqlConnection.Open();
                return cmd.ExecuteReader(CommandBehavior.CloseConnection);
            }
        }

    }       public static int Operate(string cmdString)
    {
        SqlConnection sqlConnection = new SqlConnection(connectionString);
        using (SqlCommand command = new SqlConnection(connectionString))
        {
            sqlConnection.Open();
            return cmd.ExecuteNonQuery();
        }
        
            
      
    }
    public static DataTablze DataTable(string cmdString)
    {
        SqlConnection sqlConnection = new SqlConnection(SqlConnectionString);
        SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString, connectionString);
        DataTable table = new DataTable();
        dataAdapter.Fill(table);
        return table;
    }
}
